1 00:00:00,270 --> 00:00:04,770 Now let's work on our buy button so that we can actually purchase things from our shop. 2 00:00:04,770 --> 00:00:06,770 So I am in the shop script. 3 00:00:06,780 --> 00:00:08,520 The shop script is on the shop frame. 4 00:00:08,520 --> 00:00:10,240 The shop frames in the screen do. 5 00:00:10,320 --> 00:00:12,060 So in my shop script. 6 00:00:12,060 --> 00:00:14,400 I'm going to scroll up to the top. 7 00:00:14,430 --> 00:00:16,050 I'm going to get two variables. 8 00:00:16,050 --> 00:00:25,500 I'm going to get one local player equals, I'm going to get one for the player game, get service players 9 00:00:25,830 --> 00:00:28,050 and I'll do a dot logo player. 10 00:00:28,050 --> 00:00:33,750 I need the player because I need to check to see if he has enough money or she has enough money before 11 00:00:33,750 --> 00:00:35,730 we do the purchasing of the server side. 12 00:00:36,180 --> 00:00:41,760 And I also need the buy button buy button that is on my shop frame. 13 00:00:42,300 --> 00:00:44,940 Underneath the shop brain, we have our two buy frame. 14 00:00:44,940 --> 00:00:48,060 Underneath the two buy frame, we have our buy button. 15 00:00:48,060 --> 00:00:52,590 So when someone presses the buy button, let's go down here. 16 00:00:53,280 --> 00:01:04,440 We'll get our buy button dot activated, connect that to a function and we need to check to see if there's 17 00:01:04,440 --> 00:01:06,270 something in the preview frame. 18 00:01:06,270 --> 00:01:06,510 Right. 19 00:01:06,510 --> 00:01:13,590 So we'll do it if preview name dot text. 20 00:01:13,590 --> 00:01:17,850 And I'm just going to check the name because we update the name and the price at the same time. 21 00:01:17,850 --> 00:01:25,170 So I'm going to check to see if it's not equal to an empty string because I'm going to clear out the 22 00:01:25,170 --> 00:01:26,850 strings with nothing is selected. 23 00:01:26,850 --> 00:01:30,180 If you put like nothing selected, you'll have to account for that. 24 00:01:30,180 --> 00:01:44,040 So if player dot leader stats, dot points, dot value is greater than or equal to well, we're going 25 00:01:44,040 --> 00:01:47,400 to check the preview price, but that's text. 26 00:01:47,400 --> 00:01:50,850 So we're going to need to do this two number conversion. 27 00:01:50,850 --> 00:01:58,200 Then we'll do preview price dot text then. 28 00:01:58,200 --> 00:02:02,070 So we're just changing the text and the preview price to a number. 29 00:02:02,070 --> 00:02:03,690 And then this is a number, right? 30 00:02:03,690 --> 00:02:05,340 This is an int value. 31 00:02:06,090 --> 00:02:09,900 All right, let's do our shop. 32 00:02:10,140 --> 00:02:15,810 Ari So the the we have enough points to buy the thing. 33 00:02:15,810 --> 00:02:17,040 The thing was selected. 34 00:02:17,040 --> 00:02:21,720 We're going to fire the server, fire to the server and say, Hey, buy this. 35 00:02:21,720 --> 00:02:26,340 So I'm going to say preview name, dot, text. 36 00:02:26,340 --> 00:02:29,610 And now this is a little bit dangerous. 37 00:02:29,640 --> 00:02:33,150 A lot of security people are going to are going to get a little bit excited. 38 00:02:33,150 --> 00:02:36,150 But we we can we can fix this easily. 39 00:02:36,420 --> 00:02:41,880 I'm actually going to pass the price right price dot text. 40 00:02:42,660 --> 00:02:45,690 We could do the checks on the other side if we get time. 41 00:02:46,140 --> 00:02:47,490 I'm not really that concerned. 42 00:02:47,490 --> 00:02:53,820 But what could happen is somebody because this is going to be client code, somebody could put a very 43 00:02:53,820 --> 00:02:57,840 large negative number in here sending it to the server. 44 00:02:57,840 --> 00:03:02,190 And now your leader stats is like 10 million and you get the gun, right? 45 00:03:02,190 --> 00:03:06,030 So we should we should account for that. 46 00:03:06,720 --> 00:03:11,450 It's rare, but if you get a big game, someone, someone's going to figure it out. 47 00:03:11,460 --> 00:03:16,170 So if something was not or something was not selected. 48 00:03:16,170 --> 00:03:23,250 So if this failed, then we did not have something select Oh, I'm sorry, this one is going to be. 49 00:03:23,890 --> 00:03:25,420 We did not have enough money. 50 00:03:25,660 --> 00:03:28,120 So here's my ls for this f let's. 51 00:03:28,120 --> 00:03:29,230 I'm the only thing I'm going to do. 52 00:03:29,230 --> 00:03:32,350 And else for this one, it'll just pass through if you don't have anything selected. 53 00:03:32,350 --> 00:03:33,150 So do I. 54 00:03:33,190 --> 00:03:37,570 Not enough money. 55 00:03:39,020 --> 00:03:39,440 All right. 56 00:03:39,440 --> 00:03:40,290 We could do a printout. 57 00:03:40,310 --> 00:03:41,010 Let's do a printout. 58 00:03:41,030 --> 00:03:41,530 Just check. 59 00:03:41,540 --> 00:03:42,620 Make sure it's working. 60 00:03:42,650 --> 00:03:44,240 So I'll do a print. 61 00:03:45,260 --> 00:03:48,860 We don't have anything catching that server event, so we don't have to worry about buying anything 62 00:03:48,860 --> 00:03:49,600 right now. 63 00:03:49,610 --> 00:03:53,060 Let's say buying dot, dot, dot. 64 00:03:53,120 --> 00:03:55,880 Even though we don't have to worry about it, we're willing to admit it. 65 00:03:57,140 --> 00:03:59,490 Passing the name dot text. 66 00:03:59,510 --> 00:04:00,530 Cool. 67 00:04:01,130 --> 00:04:01,760 Let's try it. 68 00:04:02,940 --> 00:04:03,660 Play. 69 00:04:08,900 --> 00:04:10,160 And as my little bell. 70 00:04:11,780 --> 00:04:12,830 Dang. 71 00:04:13,370 --> 00:04:15,350 Oh, we got to look at our output window. 72 00:04:15,770 --> 00:04:16,550 Looking good. 73 00:04:16,550 --> 00:04:17,480 No errors. 74 00:04:17,960 --> 00:04:19,580 That's a little scrunched up here. 75 00:04:19,850 --> 00:04:24,950 We could work on that if we want to do a famous lemon by it. 76 00:04:26,020 --> 00:04:27,940 Buying famous lemon. 77 00:04:28,180 --> 00:04:31,840 So our money is sufficient because I have like 2000 points now. 78 00:04:33,080 --> 00:04:35,300 And we're not subtracting because we're not actually buying them. 79 00:04:35,300 --> 00:04:36,110 But that's all right. 80 00:04:36,110 --> 00:04:37,250 We'll go ahead and do that. 81 00:04:37,940 --> 00:04:39,750 If we move this in. 82 00:04:39,830 --> 00:04:41,020 Oh, yeah, that works. 83 00:04:41,030 --> 00:04:47,120 Oh, that's because I have my image based on the aspect ratio is cuing off of the width. 84 00:04:47,120 --> 00:04:50,650 So if I do it this way, I'm all right. 85 00:04:50,660 --> 00:04:55,160 I think I'm going to stay with that, though, because if you're on a phone, it's more likely the width 86 00:04:55,160 --> 00:04:57,500 is going to actually mess you up. 87 00:04:58,100 --> 00:04:58,430 All right. 88 00:04:58,430 --> 00:05:02,030 Let's go ahead and do the server side now to complete the purchase.